<%@ page language="java" import="java.util.*,com.lab.po.Student" pageEncoding="utf-8"%>
<%@ page import="com.lab.dao.StudentDao"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
	+ request.getServerName() + ":" + request.getServerPort()
	+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>更新学生信息</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery-1.8.3.js"></script>
	<style type="text/css">
	  span{color:red;}
	  .form-signin .form-signin-heading,.form-signin .checkbox {
	margin-bottom: 10px;
}
.form-signin input[type="text"],.form-signin input[type="password"] {
	font-size: 16px;
	height: auto;
	margin-top: 8px;
	padding: 7px 9px;
}
.form-signin {
	max-width: 550px;
	padding: 19px 29px 29px;
	margin:0 auto;
	background-color: #fff;
	border: 1px solid #e5e5e5;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
	box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
	</style>

	</head>
<script>
	$(document).ready(function(){
		
		$("#college").change(function(){
			var col_id=$("#college").val();
			$("#major").empty();
			
			$.ajax({
				url:"${pageContext.request.contextPath}/colMajAjaxServlet",
				type:"post",
				data:{"col_id":col_id,},
				dataType:"json",
				success:function(result){
					$.each(result,function(inx,ele){

						$("#major").append("<option value="+ele.maj_id+" name=\"skinds_name\">"+ele.maj_name+"</option>");
						
					})
				}
			})
		})
	})
</script>	
	<body>
		
		<form class="form-signin" action="updateServlet?method=updateStudent" method="post" onSubmit="return checkstAge() && 
		checkstSex() && checkstTel() && checkstDept() && 
		checkstAddress() && checkstName()">
			学号：
			<input type="text" name="stId" value="${student.stId }" readonly="readonly"  class="input">
			<br>
			姓名：
			<input class="input" type="text" name="stName" value="${student.stName }" 
			onblur="checkstName()" onFocus="clearstName()" >
			<span id="stName1"></span>
			<br>
			性别：
			<input type="radio" name="stSex" value="男" onblur="checkstSex()"  ${student.stSex eq '男'?'checked':'' }>男
			<input type="radio" name="stSex" value="女" onblur="checkstSex()" ${student.stSex eq '女'?'checked':'' }>女
			<span id="stSex1"></span>
			<br>
			年龄：
			<input class="input" type="text" name="stAge" value="${student.stAge }" onblur="checkstAge()" onFocus="clearstAge()" >
			<span id="stAge1"></span>
			<br>
			电话：
			<input class="input" type="text" name="stTel" value="${student.stTel }" onblur="checkstTel()" onFocus="clearstTel()" >
			<span id="stTel1"></span>
			<br>
			学院：
				<select name="college" id="college" style="width: 150px">
					<c:forEach items="${collegeList}" var="college" >
						<c:if test="${college.col_id==student.col_id }">
							<option value="${college.col_id }" name="col_name" selected="selected">${college.col_name }</option>
						</c:if>
						<c:if test="${college.col_id!=student.col_id }">
							<option value="${college.col_id }" name="col_name">${college.col_name }</option>
						</c:if>
					</c:forEach>
				</select>
			<br>
			专业：
				<select name="major" id="major" style="width: 150px">
					<c:forEach items="${majorList}" var="major" >
						<c:if test="${major.maj_id==student.maj_id}">
							<option value="${major.maj_id }" name="maj_name" selected="selected">${major.maj_name }</option>
						</c:if>
						<c:if test="${major.maj_id!=student.maj_id}">
							<option value="${major.maj_id }" name="maj_name">${major.maj_name }</option>
						</c:if>
						
					</c:forEach>
				</select>
			<br>
			籍贯：
			<input class="input" type="text" name="stAddress" value="${student.stAddress }" onblur="checkstAddress()" onFocus="clearstAddress()" >
			<span id="stAddress1"></span>
			<br>
			<input type="submit" value="提交" class="btn btn-primary">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button" class="btn btn-success" onclick="window.location.href='main.jsp'"  value="返回"> 
		</form>
	</body>
</html>
